<?php
/* @var $this RosterController */
/* @var $year,$currentWeek,$previousWeek,$nextWeek  string */


if (Yii::app()->request->isAjaxRequest){
		Yii::app()->clientScript->scriptMap['jquery.js'] = false;
		Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;	
		Yii::app()->clientScript->scriptMap['jquery.ba-bbq.js'] = false;	
		Yii::app()->clientScript->scriptMap['jquery.yiigridview.js'] = false;	
	
} 



//date processing
$week_start = new DateTime();
$week_start->setTimeZone(new DateTimeZone("America/Costa_Rica"));
$week_start->setISODate($year,$currentWeek);	
$monday = $week_start->format('Y-m-d');
$sunday = date('Y-m-d',  strToTime('next Sunday '.$week_start->format('Y-m-d')));


?>


<?php

echo "<center>";
?>
<h3>Viewing Week <?php echo $currentWeek; ?> -  <?php echo $year; ?>   </h3>

From <?php echo $monday;?> thru <?php echo $sunday;?>
<br>



<?php
echo "</center>";


$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'id',
	'dataProvider'=>$this->getWeekSchedulesGrid(Yii::app()->user->team_id,$currentWeek,$year),
	//'summaryText' => '',
	'enableSorting' => false,
	'columns'=>array(
		
		array(
			'name'=>'batch',
			'header'=>'Batch#',
			'value'=>'$data[\'batch\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),
		),
		//'iduser',
		array(
			'name'  => 'User',
			//'value' => 'CHtml::link($data[\'username\'],Yii::app()->createUrl("user/view",array("id"=> $data[\'iduser\'])))',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'username\'],
					  Yii::app()->createUrl("roster/ajaxUserView",array("id"=> $data[\'iduser\'])),
					  array(\'update\' => \'#leftVisor\')
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),
		array(
			'name'  => 'Monday',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'monday\'],
					  Yii::app()->createUrl("roster/ajaxViewSchedule",
											array("id"=> $data[\'iduser\'],"date"=>$data[\'mondayDate\'])),
					  array(\'update\' => \'#leftVisor\'),
					  array("title"=>$data[\'mondayDate\'],"id" => "monday-link-".$data[\'username\']."-".$data[\'mondayDate\'])
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;', 'live'=>false,
							 ),									  
		),		
		//'mondayDate',
		array(
			'name'  => 'Tuesday',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'tuesday\'],
					  Yii::app()->createUrl("roster/ajaxViewSchedule",
											array("id"=> $data[\'iduser\'],"date"=>$data[\'tuesdayDate\'])),
					  array(\'update\' => \'#leftVisor\'),
					  array("title"=>$data[\'tuesdayDate\'],"id" => "tuesday-link-".$data[\'username\']."-".$data[\'tuesdayDate\'])
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;','live'=>false,
							 ),									  
		),	
		//'tuesdayDate',
		array(
			'name'  => 'Wednesday',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'wednesday\'],
					  Yii::app()->createUrl("roster/ajaxViewSchedule",
											array("id"=> $data[\'iduser\'],"date"=>$data[\'wednesdayDate\'])),
					  array(\'update\' => \'#leftVisor\'),
					  array("title"=>$data[\'wednesdayDate\'],"id" => "wednesday-link-".$data[\'username\']."-".$data[\'wednesdayDate\'])
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;','live'=>false,
							 ),									  
		),	
		//'wednesdayDate',
		array(
			'name'  => 'Thursday',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'thursday\'],
					  Yii::app()->createUrl("roster/ajaxViewSchedule",
											array("id"=> $data[\'iduser\'],"date"=>$data[\'thursdayDate\'])),
					  array(\'update\' => \'#leftVisor\'),
					  array("title"=>$data[\'thursdayDate\'],"id" => "thursday-link-".$data[\'username\']."-".$data[\'thursdayDate\'])
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;','live'=>false,
							 ),									  
		),	
		//'thursdayDate',
		array(
			'name'  => 'Friday',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'friday\'],
					  Yii::app()->createUrl("roster/ajaxViewSchedule",
											array("id"=> $data[\'iduser\'],"date"=>$data[\'fridayDate\'])),
					  array(\'update\' => \'#leftVisor\'),
					  array("title"=>$data[\'fridayDate\'],"id" => "friday-link-".$data[\'username\']."-".$data[\'fridayDate\'])
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;','live'=>false,
							 ),									  
		),	
		//'fridayDate',
		array(
			'name'  => 'Saturday',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'saturday\'],
					  Yii::app()->createUrl("roster/ajaxViewSchedule",
											array("id"=> $data[\'iduser\'],"date"=>$data[\'saturdayDate\'])),
					  array(\'update\' => \'#leftVisor\'),
					  array("title"=>$data[\'saturdayDate\'],"id" => "saturday-link-".$data[\'username\']."-".$data[\'saturdayDate\'])
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;','live'=>false,
							 ),									  
		),	
		//'saturdayDate',
		array(
			'name'  => 'Sunday',
			'type'  => 'raw',
			'value'=>'CHtml::ajaxLink ($data[\'sunday\'],
					  Yii::app()->createUrl("roster/ajaxViewSchedule",
											array("id"=> $data[\'iduser\'],"date"=>$data[\'sundayDate\'])),
					  array(\'update\' => \'#leftVisor\'),
					  array("title"=>$data[\'sundayDate\'],"id" => "sunday-link-".$data[\'username\']."-".$data[\'sundayDate\'])
					  )',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;','live'=>false,
							 ),									  
		),	
		//'sundayDate',
	),
)); ?>

<i>
* = Qshift Swap
<br>
** = Shift Change

